﻿@{
    ViewBag.Title = "SaveCustomInfo";
}

@{
    ViewBag.Title = "cedit";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />       
}

<form id="form1" method="post">
            @Html.Partial("~/Views/Modular/Toolbars.cshtml")
        <div name="Base" title="客户资料" style="height:100%;overflow:hidden;margin-top:15px;margin-left:20px">
            <table>
                <tr>
                    <td width="150px" height ="35px" align="right">
                        应用名称：</td>
                    <td width="300px" height ="35px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:300px;" TabIndex="2"/>
                    </td>
                </tr>
                <tr>
                    <td width="150px" height ="35px" align="right">
                        小程序AppID：</td>
                    <td width="300px" height ="35px">
                        <input name="FAppID" id="FAppID" class="mini-textbox" style="width:300px;" value="" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                    <td width="150px" height ="35px" align="right">
                        小程序AppSecret：</td>
                    <td width="300px" height ="35px">
                        <input id="FAppSecret" name="FAppSecret" class="mini-textbox " style="width:300px;"  TabIndex="4"/>
                    </td>
                </tr>
               @* <tr>
                    <td width="150px" height ="35px" align="right">
                        商城小程序AppID：</td>
                    <td width="300px" height ="35px">
                        <input name="FMallAppID" id="FMallAppID" class="mini-textbox" style="width:300px;" value="" TabIndex="1"/>
                    </td>
                </tr>
                <tr>
                    <td width="150px" height ="35px" align="right">
                        商城小程序AppSecret：</td>
                    <td width="300px" height ="35px">
                        <input id="FMallAppSecret" name="FMallAppSecret" class="mini-textbox " style="width:300px;"  TabIndex="4"/>
                    </td>
                </tr>*@
                <tr>
                    <td width="150px" height ="35px" align="right">
                        备注：</td>
                    <td width="300px" height ="35px">
                        <input name="FRemark" id="FRemark" class="mini-textbox" style="width:300px;"  value="" TabIndex="5"/>
                    </td>
                </tr>
            </table>
            <br />
        </div>
    <input name="FItemID" class="mini-hidden" />
</form>

<script>
    function FormShown() {
        mini.parse();
    }

    //加载资料
    function SetInfoData(data) {
        if (data.action == "new") {
            //跨页面传递的数据对象，克隆后才可以安全使用
            NewInfo();
        }
        else {
            $.post("GetMiniSet", { json: "[{'FItemID':'" + data.FItemID + "','mSystemAppID':'" + parent.window.getSystemAppID() + "'}]" }, function (data) {
                var form = new mini.Form("form1");
                var mdata = mini.decode(data);
                mini.getbyName("FItemID").setValue(mdata.data[0].FItemID);
                form.setData(mdata.data[0]);
            });
        }
    }

    //保存资料
    function SaveInfo() {
        mini.getbyName("SaveInfo").enable = false;
        var form = new mini.Form("#form1");
        var valid = true;
        if (mini.getbyName("FAppID").getValue() == '') {
            valid = false;
            mini.alert("AppID没有输入");
        }
        if (mini.getbyName("FAppSecret").getValue() == '') {
            valid = false;
            mini.alert("AppSecret没有输入");
        }
        if (mini.getbyName("FName").getValue() == '') {
            valid = false;
            mini.alert("应用名称没有输入");
        }

        if (valid == false) {
            mini.getbyName("SaveInfo").enable=true;
            return;
        }
        var data = form.getData(true, false);

        var json = mini.encode(data);
        $.post("SaveMiniInfo", { json: json, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                NewInfo();
            }
            else {
                mini.alert("异常:" + ret.error);
            }
            mini.getbyName("SaveInfo").enable=true;
        });
    }

</script>